package program;

public class Player {
	Konto KontoC = new Konto();
	private String name;
	private int color;
	private boolean gameLost = false; //Game status, if true then that player lost, and someone else will win.
	private boolean gameWon = false;
	private int currentField = 0;
	private boolean inJail = false;		//Om spilleren er i fèª…gsel
	private boolean hasJailcard = false;	//Hvis spilleren har mindst é¨� jailcard = true
	private int jailcardCount = 0;	//Antal jailcards spilleren har
	private boolean hasLandedOnLuck = false;	//Hvis spilleren er landet pï¿½et lykkefelt = true
	private boolean luckycardMove = false;	//For at controlleren ved at den skal udskrive at spilleren er flyttet felt
	
	public Player(String string, int color) {
		name = string;
		this.color = color;
	}
	
	public boolean getWon(){
		return gameWon;
	}
	
	public void setWon(boolean wonStatus){
		gameWon = wonStatus;
	}
	
	public boolean getLost(){
		return gameLost;
	}
	
	public void setLost(boolean status){
		gameLost = status;
	}
		
	public boolean withdraw(int withdrawValue){
		return KontoC.withdraw(withdrawValue);
	}
	
	public void deposit(int depositValue){
		KontoC.deposit(depositValue);
	}
	
	public String getName(){
		return name;
	}
		
	public int getSaldo(){
		int saldo;
		saldo = KontoC.getSaldo();
		return saldo;
	}
	
	//fx. type = shipping, changeOwn = true
	//Ville give kontoen +1 shipment ejet, hvilket èª…dre payment for shipping og brewery etc.
	public void setOwned(int[][][] newOwned){
		KontoC.setOwned(newOwned);
	}
	
	public int[][][] getOwned(){
		int[][][] owned = KontoC.getOwned();
		return owned;
	}
	
	public int getCurrentField()
	{
		return currentField;
	}
	
	public void setCurrentField(int currentField)
	{
		this.currentField = currentField;
		if (currentField == 30)
		{
			setInJail(true);
		}
		else
		{
			setInJail(false);
		}
	}
	public boolean inJail()
	{
		return inJail;
	}
	
	public void setInJail(boolean inJail)
	{
		this.inJail = inJail;
	}

	public void moveForward(int sum, boolean recievePayment)
	{
		if (getCurrentField()+sum < 40)
		{
			setCurrentField(Math.abs(getCurrentField()+sum));
		} 
		//Flytter spilleren hen over start nèšŒ sum > 40
		else 
		{
			int rest = Math.abs(getCurrentField()+sum-40);
			setCurrentField(rest);
			if (recievePayment)
			{
				deposit(4000);	//FèšŒ udbetalt 4000 kr. for at kî˜’e over Start
			}
		}
	}
	
	public void moveBack(int sum)
	{
		if (getCurrentField()-sum >= 0)
		{
			setCurrentField((getCurrentField()-sum));
		} 
		//Flytter spilleren hen over start nèšŒ sum < 0
		else 
		{
			int rest = (getCurrentField()-sum+40);
			setCurrentField(rest);
		}
	}
	
	public boolean hasJailcard()
	{
		return hasJailcard;
	}
	
	public void giveJailCard()
	{
		jailcardCount++;
		hasJailcard = true;
	}
	
	public void removeJailcard()
	{
		jailcardCount--;
		setInJail(false);
		if (jailcardCount == 0)
		{
			hasJailcard = false;
		}
	}
	
	public boolean hasLandedOnLuck()
	{
		return hasLandedOnLuck;
	}
	
	public void setLandedOnLuck(boolean hasLandedOnLuck)
	{
		this.hasLandedOnLuck = hasLandedOnLuck;
	}
	
	public boolean luckycardMove()
	{
		return luckycardMove;
	}
	
	public void setLuckycardMove(boolean luckycardMove)
	{
		this.luckycardMove = luckycardMove;
	}
}
